//
// Created by WangPeng on 2024/8/15.
//

#ifndef RTSP_H264_SERVER_SERV_SK_H
#define RTSP_H264_SERVER_SERV_SK_H


#include <string>
#include <cstdint>
#include <map>

struct st_ip
{
    uint32_t iip;
    std::string sip;
    st_ip(uint32_t ip, std::string str_ip)
        : iip(ip), sip(std::move(str_ip))
    {

    }
};

class CServSocket
{
public:
    CServSocket(std::string ip, int port);
    ~CServSocket();
    int serv_fd() const
    {
        return server_fd_;
    }
    int accept_conn();
    //get number type ip
    uint32_t get_number_ip(int fd) const;
    std::string get_string_ip(int fd) const;
private:
    static int set_non_blocking(int fd);
private:
    std::string ip_{};
    int port_{};
    int server_fd_{-1};
    std::map<int, st_ip> client_ips_{};
};


#endif //RTSP_H264_SERVER_SERV_SK_H
